<?php

class orgs extends Controller {

	function index() {
		$orgs = new organization();
		$orgList = $orgs->getOrgSummaries();
		new View('siteAdmin/template',
			array(
				'title' => new BufferedView('siteAdmin/titles/tOrganizations'),
				'content' => new BufferedView('siteAdmin/organizations',	array('organization' => $orgList) )
			)
		);
	}	
	
	function add($confirm = null) {
		if( $confirm === null )  {
			new View('siteAdmin/template',
				array(
					'title' => new BufferedView('siteAdmin/titles/tOrganizations'),
					'content' => new BufferedView('siteAdmin/orgs/add')
				)
			);
		}
		else if( $confirm === 'confirm' ){
			$orgs = new organization();
			$orgs->insertOrg($_POST['name'], '', '', ''); //intentionally blank last three parameters
			new View('siteAdmin/template',
				array(
					'title' => new BufferedView('siteAdmin/titles/tOrganizations'),
					'content' => new BufferedView('emptyTemplate',
						array('message' => 'Organization has been created. Click <a href="admin/orgs/members">here</a> to go back to the organization list.')
					),
				)
			);
		}
	}
	
	function delete() {
		if( $confirm === null )  {
			new View('siteAdmin/template');
		}
		else if( $confirm === 'confirm' ){
			new View('siteAdmin/template');
		}
	}
	
	function edit() {
		if( $confirm === null )  {
			new View('siteAdmin/template');
		}
		else if( $confirm === 'confirm' ){
			new View('siteAdmin/template');
		}
	}

	function members( $id, $select = null ) {
		if( $select === null ) {
			new View('siteAdmin/template',
				array(
					'title' => new BufferedView('siteAdmin/tOrganizations')
					'content' => new BufferedView('siteAdmin/orgs/select',
						array( )
					)
				)
			);
		}
		else if( $select === 'select' ) {
			new View('siteAdmin/template',
				array(
					'title' => new BufferedView('siteAdmin/titles/tOrganizations')
				)
			);
		}
	}
	
}
